import advView from '$v/adv'
//引入切换路由权限验证
import {
  isLoginRequest,
  loginOutRequest
} from "$a/admin"
export default async(req, res, next) => {
  //切换路由权限验证
  try {
  await isLoginRequest()
  } catch (e) {
    alert("有异常"+e.message)
    if (!e.isLogin) {
      router.go("/login")
    }
  };

  // res.render(advView({}))
  //二级路由需要调用next
  next(advView({
    subRoute: res.subRoute(),
    url: req.url //高亮需要匹配路径做判断  左侧导航栏属于一级路由区域,所以在一级路由传 
  }))

  const out = document.querySelector("#loginOut")
  out.onclick =async function() {
    //退出登录
    try {
    const outResult=  await loginOutRequest()
      alert ("退出成功")
      router.go("/login")
    } catch (e) {
      alert("退出失败"+e.message)
    }
  }

  //添加图片
}